package android.hoopmedia.hoopmediaplayerdemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {
    private final static String TAG = "AcSdk_ArenaCloudStreamViewActivity";

    public String rtmpAddress1;
    public String rtmpAddress2;

    private EditText urlEditText1;
    private EditText urlEditText2;

    private String publicKey = "1c76aec81ad398126f5f5d2eda531c89";
    private String id = "7f25edf7ad0cf251611000dd";
    private String password = "cd30b0dd";
    private String ticket = "ZT0xNDc3NTU4NTQ4JmM9MTIzNDU2Nzg5MCZzPXczYWFnQi1Jc1ZqQzhGQzFpR194QUFHYzB4eFU5NDE4U1BGQ094cEcwUzQ";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);

        urlEditText1 = (EditText) this.findViewById(R.id.editText1);
        urlEditText2 = (EditText) this.findViewById(R.id.editText2);

        initLayout();
    }

    private void initLayout() {
        final Activity me = this;

        Button broadcastButton = (Button) findViewById(R.id.broadcastStream);
        broadcastButton.setText("Broadcaster");
        broadcastButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String strUrl = urlEditText1.getText().toString();

                Intent intent = new Intent(MainActivity.this, AcBroadcastActivity.class);

                intent.putExtra("WIDTH", 640);
                intent.putExtra("HEIGHT", 480);
                intent.putExtra("ORIENTATION", "portrait");
                intent.putExtra("CAMERA", "back");

                intent.putExtra("publicUrl", strUrl);
                intent.putExtra("publicKey",publicKey);
                intent.putExtra("id",id);
                intent.putExtra("password",password);
                intent.putExtra("ticket", ticket);

                startActivity(intent);
            }
        });

        Button playButton = (Button) findViewById(R.id.playStream);
        playButton.setText("Play");
        playButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                rtmpAddress1 = urlEditText2.getText().toString();
                if (rtmpAddress1.isEmpty()){
                    rtmpAddress1 = "rtmp://huputv-ws-live.arenacdn.com/prod/NvS4rQzyGQDWEJLi";
                }
                Intent intent = new Intent(MainActivity.this, AcVideoPlayerActivity.class);
                intent.putExtra("RtmpAddress", rtmpAddress1);
                startActivity(intent);
            }
        });
    }
}
